import Vue from 'vue'
import App from './App.vue'
import router from './router'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css';
import axios from 'axios'
import { getToken } from '@/utils/auth'
window.echarts = require('echarts');

Vue.use(ElementUI)
Vue.config.productionTip = false

// 添加拦截器
axios.interceptors.request.use(
  config => {
    // 是否需要设置 token
    const isToken = (config.headers || {}).isToken === false
    if (getToken() && !isToken) {
      config.headers.Authorization = getToken()
    }
    return config
  },
  error => {
    return Promise.reject(error)
  }
)

new Vue({
  router,
  render: h => h(App),
}).$mount('#app')
